<?php
/**
 * 自定义的html工具函数集
 */
class htmlutil{
	/**
	 * 搜索材料的工具
	 */
	public static function search_wares($type){
		return <<<HTML
<table class="plain"><tbody><tr class="nobg">
	<td style="border:0px;"><input type="text" id="sw_key" size="8" /></td>
	<td style="border:0px;"><input type="button" value="检索" class="button" onclick="sw_search_stuff()" /></td>
	<td style="border:0px;">&nbsp;=&gt;&nbsp;</td>
	<td style="border:0px;"><select id="sw_wareid" disabled><option value="">--</option></select></td>
	<td style="border:0px;"><input id="sw_choose" value="选择" onclick="sw_add_stuff('$type')" type="button" class="button" disabled /></td>
</tr></tbody></table>
<script> sw_init(); </script>
HTML;
	}
	
	public static function users_select($name='', $tips='', $id=''){
		static $users = null;
		if(!$users){
			$users = User::getList();
		}
		return Html::options2(array(
			'tips'	=> $tips,
			'data'	=> $users,
			'id'	=> $id,
			'name'	=> $name,
			'val'	=> fetch_a_int($name),
			'val_key'	=> 'id',
			'text_key'	=> 'name',
		));
	}
	
	static function makeTimesRangeBox($desc='时间'){
		$from = fetch_a_string('from');
		$to   = fetch_a_string('to');
		return <<<HTML
	{$desc}自：<input type="text" class="wdate" id="from" name="from" size="10" value="{$from}"
		   onfocus="WdatePicker({onpicked:function(){\$dp.\$('to').focus();},maxDate:'#F{\$dp.\$D(\'to\')}'})" readonly />
	至 <input type="text" class="wdate" id="to" name="to" size="10" value="{$to}"
		   onfocus="WdatePicker({minDate:'#F{\$dp.\$D(\'from\')}'})" readonly />
HTML;
	}

	public static function dept_select($name='', $tips='', $id=''){
		static $depts = null;
		if(!$depts){
			$depts = Dept::getList();
		}
		return Html::options2(array(
			'tips'	=> $tips,
			'data'	=> $depts,
			'id'	=> $id,
			'name'	=> $name,
			'val'	=> fetch_a_int($name),
			'val_key'	=> 'id',
			'text_key'	=> 'name',
		));
	}
	
}
?>